﻿using System;
using System.Drawing;

namespace CloudShot.Utils
{
  public static class SystemDrawingExtensions
  {
    /// <summary>
    ///   Adjusts brightness for the <paramref name="color" />
    /// </summary>
    /// <param name="color">The color.</param>
    /// <param name="percent">The percentage of brightness (values between 0 and 1).</param>
    /// <returns>The <see cref="Color" /> with adjusted brightness.</returns>
    public static Color AdjustBrightness(this Color color, float percent)
    {
      int r = Math.Min((int)(color.R * percent), 255);
      int g = Math.Min((int)(color.G * percent), 255);
      int b = Math.Min((int)(color.B * percent), 255);

      return Color.FromArgb(color.A, r, g, b);
    }
  }
}